package com.vf.admin.miaodong.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppCommentReply;
import com.vf.admin.miaodong.entity.AppMounts;
import com.vf.admin.miaodong.entity.AppUser;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * 坐骑
 */
@Repository
public class AfterMountsDao extends BaseDao<AppMounts> {

    /**
     * 查询列表
     * @return
     */
    public List<AppMounts> findList(Map<String, Object> map, SplitPageBean bean) {
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("");
        sbStr.append(" SELECT * FROM app_mounts where 1=1 ");
        if (StringEx.isNotNull(map.get("name"))) {
            sbStr.append(" and name like ? ");
            paramList.add("%" + map.get("name") + "%");
        }
        if (StringEx.isNotNull(map.get("guishu"))) {
            sbStr.append(" and guishu = ? ");
            paramList.add(map.get("guishu"));
        }
        sbStr.append(" order by createtime desc ");
        String sql = sbStr.toString();
        return this.queryList(sql, paramList, AppMounts.class, bean);
    }

    /**
     * 详情
     */
    public AppMounts get(Integer id) {
        if (StringEx.isNullOrLing(id)) {
            return null;
        }
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_mounts where 1=1");
        sbStr.append(" and id = ? ");
        paramList.add(id);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, AppMounts.class);
    }

    /**
     * 添加/修改
     */
    public void save(AppMounts haoYou) {
        if (haoYou.getId() != null && haoYou.getId() > 0) {
            this.update(haoYou);
        } else {
            haoYou.setId(this.add(haoYou));
        }
    }

    /**
     * 删除
     */
    public void del(Integer id) {
        if (id <= 0) {
            return;
        }
        String sql = "delete  from app_mounts where id = ?";
        ArrayList<Object> paramList = new ArrayList<Object>();
        paramList.add(id);
        this.del(sql, paramList);
    }


}
